﻿@model SportsStore.WebUI.Models.CartIndexViewModel

@{
    ViewBag.Title = "Sports Store: Your Cart";
}

<h2>Your Cart</h2>
<table width="90%" align="center">
    <thead>
        <tr>
            <th align="center">Quantity</th>
            <th align="left">Item</th>
            <th align="right">Price</th>
            <th align="left">SubTotal</th>
            <th align="left"></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var line in Model.cart.Lines)
        {   
            <tr>
                <td align="center">@line.Quantity</td>
                <td align="left">@line.Product.Name</td>
                <td align="right">@line.Product.Price</td>
                <td align="right">@((line.Product.Price * line.Quantity).ToString("c"))</td>
                <td>@using(Html.BeginForm("RemoveFromCart","Cart")){
                        @Html.Hidden("ProductId", line.Product.ProductID);
                        @Html.HiddenFor(x => x.ReturnUrl)
                        <input class="actionButtons" type="submit" value="Remove" />
                    }
                </td>
            </tr>
        }
    </tbody>
    <tfoot>
        <tr>
            <td colspan="5" align="right">Total: @Model.cart.ComputeTotalValue().ToString("c")</td>
        </tr>
    </tfoot>
</table>
<p align="center" class="actionButtons">
    <a href="@Model.ReturnUrl">Continue Shoping..</a>
    @Html.ActionLink("Checkout now", "Checkout")
</p>